package mule;

import static org.junit.Assert.*;

import java.awt.Color;
import java.util.ArrayList;

import org.junit.Test;

public class SaveLoadTest {
	Player player1 = new Player(1, 1, Color.RED, "1");
	Player player2 = new Player(1, 1, Color.BLUE, "2");
	Player player3 = new Player(1, 1, Color.GREEN, "3");
	Player player4 = new Player(1, 1, Color.YELLOW, "4");
	ArrayList<Player> arr = new ArrayList<Player>();

	/**
	 * Test to make sure the game being saved is the same as the loaded game,
	 * add a new player for each test
	 */
	@Test
	public void testOnePlayer() {
		arr.add(player1);
		Game game1 = new Game(true, 1, new Map(5, 9), arr, 1);
		Game.saveGame("game1");
		Game game2 = MainMenu.loadGame("game1");
		assertEquals(Game.playerArray, Game.playerArray);
		assertEquals(Game.roundNumber, Game.roundNumber);
		assertEquals(Game.turns, Game.turns);
		assertEquals(Game.playerArray.toString(), Game.playerArray.toString());
		assertEquals(Game.player, Game.player); // current player
	}

	@Test
	public void testTwoPlayers() {
		arr.add(player2);
		Game game1 = new Game(true, 1, new Map(5, 9), arr, 1);
		Game.saveGame("game1");
		Game game2 = MainMenu.loadGame("game1");
		assertEquals(Game.playerArray, Game.playerArray);
		assertEquals(Game.roundNumber, Game.roundNumber);
		assertEquals(Game.turns, Game.turns);
		assertEquals(Game.playerArray.toString(), Game.playerArray.toString());
		assertEquals(Game.player, Game.player); // current player
	}

	@Test
	public void testThreePlayers() {
		arr.add(player3);
		Game game1 = new Game(true, 1, new Map(5, 9), arr, 1);
		Game.saveGame("game1");
		Game game2 = MainMenu.loadGame("game1");
		assertEquals(Game.playerArray, Game.playerArray);
		assertEquals(Game.roundNumber, Game.roundNumber);
		assertEquals(Game.turns, Game.turns);
		assertEquals(Game.playerArray.toString(), Game.playerArray.toString());
		assertEquals(Game.player, Game.player); // current player
	}

	@Test
	public void testFourPlayers() {
		arr.add(player4);
		Game game1 = new Game(true, 1, new Map(5, 9), arr, 1);
		Game.saveGame("game1");
		Game game2 = MainMenu.loadGame("game1");
		assertEquals(Game.playerArray, Game.playerArray);
		assertEquals(Game.roundNumber, Game.roundNumber);
		assertEquals(Game.turns, Game.turns);
		assertEquals(Game.playerArray.toString(), Game.playerArray.toString());
		assertEquals(Game.player, Game.player); // current player
	}
}
